package com.xbongbong.saas.service;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.pojo.FieldAttrEntityForImport;
import com.xbongbong.paas.pojo.dto.FormDataAddDTO;
import com.xbongbong.paas.pojo.dto.FormDataListDTO;
import com.xbongbong.paas.pojo.dto.ImportFormDataDTO;
import com.xbongbong.paas.pojo.dto.SaasFormSaveDTO;
import com.xbongbong.paas.pojo.dto.ValidateDataDTO;
import com.xbongbong.paas.pojo.dto.WarehouseCheckDTO;
import com.xbongbong.paas.pojo.imports.CellTitlePojo;
import com.xbongbong.paas.pojo.imports.RowGroupPojo;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.businessdata.pojo.dto.FormatExplainDTO;
import com.xbongbong.pro.businessproduct.pojo.dto.BusinessProductListDTO;
import com.xbongbong.pro.detailtab.vo.ProductSummaryVO;
import com.xbongbong.pro.inventory.pojo.dto.InventoryDeleteBatchDTO;
import com.xbongbong.pro.inventory.pojo.dto.InventoryEditAttrUpdateDTO;
import com.xbongbong.pro.inventory.pojo.dto.InventoryResetInstockIdDTO;
import com.xbongbong.pro.inventory.pojo.dto.InventoryResetOutstockIdDTO;
import com.xbongbong.pro.inventory.pojo.dto.InventoryUpdateBatchDTO;
import com.xbongbong.pro.inventory.pojo.dto.InventoryUpdateByBusinessRuleDTO;
import com.xbongbong.pro.inventory.pojo.vo.InventoryDeleteBatchVO;
import com.xbongbong.pro.inventory.pojo.vo.InventoryResetInstockIdVO;
import com.xbongbong.pro.inventory.pojo.vo.InventoryResetOutstockIdVO;
import com.xbongbong.pro.inventoryproduct.pojo.dto.FormatInventoryProductDTO;
import com.xbongbong.pro.listbatch.pojo.dto.AddLabelDTO;
import com.xbongbong.pro.product.pojo.dto.PagingProductDTO;
import com.xbongbong.pro.product.pojo.vo.DetailProductVO;
import com.xbongbong.pro.product.pojo.vo.PagingProductVO;
import com.xbongbong.pro.warehouse.pojo.vo.WarehouseListVO;
import com.xbongbong.saas.domain.entity.InventoryProductEntity;
import com.xbongbong.saas.domain.entity.ProductBaseInfoEntity;
import com.xbongbong.saas.enums.UpdateDataTypeEnum;

import java.util.List;
import java.util.Map;

/**
 * 盘点单业务处理
 * @author feng.zheng
 * @version v1.0
 * @date 2019/1/22
 * @since v1.0
 */
public interface InventoryService {
    /**
     * 盘点单保存前saas特殊校验
     *
     * @param validateDataDTO saas特殊校验数据入参
     * @throws XbbException 业务异常
     * @author feng.zheng
     * @date 2019/1/18
     */
    void beforeSave(ValidateDataDTO validateDataDTO) throws XbbException;

    /**
     * 盘点单保存后逻辑
     *
     * @param saasFormSaveDTO saas保存数据
     * @throws XbbException 业务异常
     * @author feng.zheng
     */
    void afterSave(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;



    /**
     * 新建时格式化解释
     *
     * @param formatExplainDTO 入参
     * @author feng.zheng
     * @throws XbbException 异常
     * @date 2019/2/27 20:11
     */
    void formatAddExplain(FormatExplainDTO formatExplainDTO) throws XbbException;

    /**
     * 批量删除盘点单
     * @author 吴峰
     * @date 2019/2/28 15:22
     * @param inventoryDeleteBatchDTO
     * @return com.xbongbong.pro.inventory.pojo.vo.InventoryDeleteBatchVO
     * @throws XbbException 业务异常
     */
    InventoryDeleteBatchVO deleteBatch(InventoryDeleteBatchDTO inventoryDeleteBatchDTO) throws XbbException;

    /**
     * 删除入库单后重置盘点单入库单Id
     * @author 吴峰
     * @date 2019/2/28 22:53
     * @param inventoryResetInstockIdDTO
     * @return com.xbongbong.pro.inventory.pojo.vo.ResetInstockIdVO
     * @throws XbbException 业务异常
     */
    InventoryResetInstockIdVO resetInstockIdByIdIn(InventoryResetInstockIdDTO inventoryResetInstockIdDTO) throws XbbException;
    /**
     * 删除出库单后重置盘点单出库单Id
     * @author 吴峰
     * @date 2019/8/23 19:56
     * @param inventoryResetOutstockIdDTO
     * @return com.xbongbong.pro.inventory.pojo.vo.InventoryResetOutstockIdVO
     * @throws XbbException 业务异常
     */
    InventoryResetOutstockIdVO resetOutstockIdByIdIn(InventoryResetOutstockIdDTO inventoryResetOutstockIdDTO) throws XbbException;

    /**
     * 获取盘点单产品
     *
     * @param businessProductListDTO 入参
     * @param jsonObject 数据对象
     * @return 产品
     * @throws XbbException 异常
     */
//    BusinessProductListVO getInventoryProductList(BusinessProductListDTO businessProductListDTO, JSONObject jsonObject) throws XbbException;

    /**
     * 格式化盘点单产品，显示给前端
     * @param dataList bom单实体数据
     * @param saasAnalysisDataDTO 数据解析DTO
     * @author feng.zheng
     * @throws XbbException 异常
     * @date 2019-02-01 15:19
     */
//    void formatProduct4Show(JSONObject dataList, SaasAnalysisDataDTO saasAnalysisDataDTO) throws XbbException;

    /**
     * 将盘点单产品格式化返回给前端
     *
     * @param formatInventoryProductDTO 格式化盘点单产品的DTO
     * @Date 22:20 2019/3/4
     * @since v1.0
     * @return 一个盘点单产品的JSONObject
     **/
    JSONObject getFormatProductJsonArray(FormatInventoryProductDTO formatInventoryProductDTO, boolean generalGetProduct, boolean detailGet) throws XbbException;

    /**
     * 批量编辑某个字段
     * @author 吴峰
     * @date 2019/3/20 14:23
     * @param inventoryEditAttrUpdateDTO
     * @return void
     * @throws XbbException 业务异常
     */
    void batchEditAttr(InventoryEditAttrUpdateDTO inventoryEditAttrUpdateDTO) throws XbbException;
    /**
     * 批量某个字段
     * @author 吴峰
     * @date 2019/3/20 14:23
     * @param inventoryUpdateBatchDTO
     * @return void
     * @throws XbbException 业务异常
     */
    void updateBatch(InventoryUpdateBatchDTO inventoryUpdateBatchDTO) throws XbbException;

    /**
     * 将Excel数据格式化成表单保存需要的JSON格式的数据
     *
     * @param importFormDataDTO 导入入参
     * @param titlePojoList     标题
     * @param rowGroupPojo      一个表单对应的一组Excel填写的数据
     * @param fieldAttrList     解释
     * @return FormDataAddDTO
     * @throws XbbException XbbException
     * @author lee
     * @date 2019/4/29 14:16
     * @since V1.0
     */
    FormDataAddDTO formatExcelValue(ImportFormDataDTO importFormDataDTO, List<CellTitlePojo> titlePojoList, RowGroupPojo rowGroupPojo, List<FieldAttrEntityForImport> fieldAttrList) throws XbbException;

    /**
     * 格式化导出值
     *
     * @param paasFormDataESList 数据
     * @throws XbbException 异常
     */
    void formatExportValue(List<PaasFormDataEntityExt> paasFormDataESList, FormDataListDTO formDataListDTO, List<FieldAttrEntityForImport> fieldAttrList) throws XbbException;

    /**
     * Description: 盘点单 仓库 一致性
     * @param corpid
     * @param dataId
     * @param name
     * @return void
     * @author 魏荣杰
     * @date 2019/8/5 10:35
     * @since v1.0
     */
    void dataConsistencyUpdateWarehouse(String corpid, Long dataId, String name) throws XbbException;

    /**
     * 根据业务规则，更新盘点单
     * @author 吴峰
     * @date 2019/8/19 16:36
     * @param inventoryUpdateByBusinessRuleDTO
     * @return void
     * @throws XbbException 业务异常
     */
    void updateBatchByBusinessRule(InventoryUpdateByBusinessRuleDTO inventoryUpdateByBusinessRuleDTO) throws XbbException;

    /**
     * 汇总盘点产品信息（详情页，几种产品几件）
     *
     * @param businessProductListDTO 入参
     * @param dataList data对象
     * @throws XbbException
     * @author long.rao
     * @date 2019-08-28 10:23
     */
    ProductSummaryVO summaryProductList(BusinessProductListDTO businessProductListDTO) throws XbbException;

    void formatProduct4Show2(Long dataId, String corpid, JSONObject data, UpdateDataTypeEnum updateDataTypeEnum) throws XbbException;

    PagingProductVO getPagingProduct(PagingProductDTO pagingProductDTO) throws XbbException;

    DetailProductVO formatProduct4DetailShow(List<InventoryProductEntity> inventoryProductEntityList, PagingProductDTO pagingProductDTO) throws XbbException;

    JSONObject formatSingleProduct(InventoryProductEntity entity,ProductBaseInfoEntity productBaseInfoEntity);

    void formatBatchExplain(List<FieldAttrEntity> fieldAttrEntityList, String enable);

    WarehouseListVO checkWarehouse(WarehouseCheckDTO warehouseCheckDTO) throws XbbException;

    void filterBatchStock(Map<Long, Map<String,JSONObject>>  productMap, List<Long> productIdList, String corpid) throws XbbException;

    void updateBatchLabelAttr(AddLabelDTO addLabelDTO, List<PaasFormDataEntityExt> addBatchList, Boolean addOrDelete) throws XbbException;

    void afterSaveForWorkflow(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;

    void afterSaveForUpdateWorkflow(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;

    /**
     * 盘点单生成出入库单
     * @param saasFormSaveDTO
     * @throws XbbException
     */
    void generateStockSheet(SaasFormSaveDTO saasFormSaveDTO) throws XbbException;
}
